<template>
  <div class="order-detail-container">
    <Header v-if="currentOrderInfo" :info="currentOrderInfo"></Header>
    <Type @getType="getVoteType" :info="currentOrderInfo"></Type>
    <Other @getIsSeat="getSeat" :info="currentOrderInfo"></Other>
    <Footer
      :info="currentOrderInfo"
      :buyType="buyType"
      :auto_check_seat="auto_check_seat"
    ></Footer>
  </div>
</template>
<script setup lang="ts">
import Header from "./header.vue";
import Type from "./type.vue";
import Footer from "./footer.vue";
import Other from "./other.vue";
import Taro from "@tarojs/taro";
import { onMounted, ref } from "vue";
import * as orderApi from "../../api/order";
const router = Taro.useRouter();
const currentOrderId: any = ref(null);
const currentOrderInfo: any = ref(null);
const buyType = ref(0);
const auto_check_seat = ref(0);
onMounted(() => {
  currentOrderId.value = router.params.id;
  getDetails();
});
const getVoteType = (val) => {
  console.log(val, "打印一下收到的类型");
  if (val) {
    buyType.value = 1;
  } else {
    buyType.value = 0;
  }
};
const getSeat = (val) => {
  console.log(val, "打印一下收到的类型");
  if (val) {
    auto_check_seat.value = 1;
  } else {
    auto_check_seat.value = 0;
  }
};

const getDetails = async () => {
  const data = {
    id: currentOrderId.value,
  };
  const res: any = await orderApi.OrderDetail(data);
  currentOrderInfo.value = res;
};
</script>
<style lang="scss">
.order-detail-container {
  display: flex;
  flex-direction: column;
  padding: 0 25px;
}
</style>
